<?php

class sradar_view_helper {

    function function_desktop_footer($params, &$smarty) {
        /* @todo 删除 zhangh
         * $Certi = base_certificate::get('certificate_id');
         * $token = base_certificate::get('token');
         * //计算商品雷达所需sign_key-start-
         * $data = array(
         * 'radar_lincense_id' => $Certi,
         * 'radar_product_key' => 'ecstore',
         * );
         * $sign_key = $this->sign($data,$token);
         * //-end-
         *
         * $html = "<input type='hidden' id='radar_lincense_id' value=$Certi >
         * <input type='hidden' id='radar_product_key' value='ecstore' >
         * <input type='hidden' id='radar_sign_key' value=$sign_key >";
         */
        $html = '';
        return $html;
    }

    function assemble($params) {
        if (! is_array($params))
            return null;
        ksort($params, SORT_STRING);
        $sign = '';
        foreach ($params as $key => $val) {
            $sign .= $key . (is_array($val) ? assemble($val) : $val);
        }
        return $sign;
    }

    // 计算商品雷达需要的sign值
    function sign($data, $token) {
        $rs = strtoupper(md5(strtoupper(md5($this->assemble($data))) . $token));
        return $rs;
    }
}
